package server.rest;

public class ResponseException extends Exception
{

    private static final long serialVersionUID = -897297957990121636L;
    private int statusCode;
    private String content;
    private String contentType;

    /**
     * Please try to use ResponseException(int statusCode, Throwable cause) instead when chaining
     * exceptions in order to show the original cause of the problem
     */
    public ResponseException(int statusCode)
    {
        this.statusCode = statusCode;
    }

    /**
     * Please try to use ResponseException(int statusCode, String message, Throwable cause) instead
     * when chaining exceptions in order to show the original cause of the problem
     */
    public ResponseException(int statusCode, String message)
    {
        super(message);
        this.statusCode = statusCode;
    }

    /**
     * Please try to use ResponseException(int statusCode,String content,String contentType,
     * Throwable cause) instead when chaining exceptions in order to show the original cause of the
     * problem
     */
    public ResponseException(int statusCode, String content, String contentType)
    {
        this(statusCode, content, contentType, null, null);
    }

    /**
     * Please try to use ResponseException(int statusCode,String content,String contentType,String
     * message, Throwable cause) instead when chaining exceptions in order to show the original
     * cause of the problem
     */
    public ResponseException(int statusCode, String content, String contentType, String message)
    {
        this(statusCode, content, contentType, message, null);
    }

    public ResponseException(int statusCode, Throwable cause)
    {
        this(statusCode, null, cause);
    }

    public ResponseException(int statusCode, String message, Throwable cause)
    {
        super(message, cause);
        this.statusCode = statusCode;
    }

    public ResponseException(int statusCode, String content, String contentType, Throwable cause)
    {
        this(statusCode, "Content=" + content, cause);
    }

    public ResponseException(int statusCode, String content, String contentType, String message, Throwable cause)
    {
        this(statusCode, "Content=" + content + ", Message=" + message, cause);
        this.content = content;
        this.contentType = contentType;
    }

    public void setStatusCode(int statusCode)
    {
        this.statusCode = statusCode;
    }

    public int getStatusCode()
    {
        return statusCode;
    }

    public void setContent(String content)
    {
        this.content = content;
    }

    public String getContent()
    {
        return content;
    }

    @Deprecated
    public void setContentType(String contentType)
    {
        this.contentType = contentType;
    }

    public String getContentType()
    {
        return contentType;
    }

}
